package com.webex.ta.hydra.gui.wm;

import com.webex.ta.hydra.gui.menu.HydraToolBar;

import javax.swing.*;
import java.awt.*;

/**
 * Created by Cisco WebEx.
 * User: vegaz
 * Date: 2010-10-20
 * Time: 9:05:26
 */
public class HydraRootPane extends JRootPane {
    private JPanel contentPane;
    private ToolWindowPane toolWindowPane;
    private HydraToolBar toolBar;

    @Override
    protected Container createContentPane() {
        contentPane = new JPanel(new BorderLayout());
        contentPane.setBackground(Color.gray);
        return contentPane;
    }

    public void setToolWindowPane(final ToolWindowPane toolWindowPane) {
        final JComponent cp = (JComponent)getContentPane();
        if (this.toolWindowPane != null)
            cp.remove(this.toolWindowPane);

        this.toolWindowPane = toolWindowPane;
        if (this.toolWindowPane != null)
            cp.add(this.toolWindowPane, BorderLayout.CENTER);

        cp.revalidate();
    }

    public void setToolBar(final HydraToolBar toolBar) {
        final JComponent cp = (JComponent)getContentPane();
        if (this.toolBar != null)
            cp.remove(this.toolBar);

        this.toolBar = toolBar;
        if (this.toolBar != null)
            cp.add(this.toolBar, BorderLayout.NORTH);

        cp.revalidate();
    }
}
